package com.yit.cn;

/**
 * Created by zhangyanfei on 2019/4/21.
 *
 * @author zhangyanfei
 * @date 2019/04/21
 */
public class PlanD extends AbstractPlan {
    private SchedulingContext schedulingContext;

    /**
     * 1.7
     *
     * 0.15
     */
    Pilot autoBpilot = new Pilot("autoB", 1.7, 0.15);

    public PlanD(SchedulingContext schedulingContext) {
        super(schedulingContext);
        this.schedulingContext = schedulingContext;

    }

    public Pilot getPilot() {
        schedulingContext.setNormalACanFly(true);
        schedulingContext.setNormalBCanFly(true);
        schedulingContext.isFly = false;
        // 大于阈值的情况下 加班
        if (schedulingContext.grandTotalDaysOfA > SchedulingContext.threshold) {
            schedulingContext.restOfA += 1;
        }
        return autoBpilot;
    }

    public boolean condition() {
        if (!schedulingContext.isFly) {
            return false;
        }
        if (!schedulingContext.isNormalACanFly() && !schedulingContext.isNormalBCanFly()) {
            // A 加班已经超过11天
            if (schedulingContext.grandTotalDaysOfA > SchedulingContext.threshold) {
                return true;
            } else {
                return false;
            }
        }
        return false;
    }

    public String getSFCofDay() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "消耗油量：" + schedulingContext.getLoad() * schedulingContext.getDistance() * autoBpilot.getSfc()
                + "吨油量;";
        } else {
            // 是Y 0.14 油耗
            return "消耗油量：" + schedulingContext.getLoad() * schedulingContext.getDistance() * 0.14 + "吨油量;";
        }

    }

    public String getElapsedTime() {
        if (schedulingContext.getAirplaneModel().equalsIgnoreCase("X")) {
            return "飞行时间：" + schedulingContext.getDistance() / autoBpilot.getFlySpeed() + "h;";
        } else {
            return "飞行时间：" + schedulingContext.getDistance() / (1.15 * autoBpilot.getFlySpeed()) + "h;";
        }
    }

}
